-
Notifications
You must be signed in to change notification settings - Fork 18
Verilog: ranged always properties #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
087a57a
to
aa3d47d
Compare
aa3d47d
to
46f69a6
Compare
src/trans-word-level/property.cpp
Outdated
mp_integer current, | ||
mp_integer no_timeframes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that mp_integer
is non-trivial, how about passing those as const references?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/trans-word-level/property.cpp
Outdated
mp_integer from, to; | ||
|
||
auto from_opt = numeric_cast<mp_integer>(range.op0()); | ||
if(!from_opt.has_value()) | ||
throw ebmc_errort() << "failed to convert SVA always from index"; | ||
|
||
from = *from_opt; | ||
|
||
if(range.op1().id() == ID_infinity) | ||
{ | ||
to = no_timeframes - 1; | ||
} | ||
else | ||
{ | ||
auto to_opt = numeric_cast<mp_integer>(range.op1()); | ||
if(!to_opt.has_value()) | ||
throw ebmc_errort() << "failed to convert SVA always to index"; | ||
to = *to_opt; | ||
} | ||
|
||
for(mp_integer c = from; c <= to; ++c) | ||
{ | ||
if(c >= 0 && c < no_timeframes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of (related) ideas:
- No need to declare
from
before it can be initialised. - Taking this one step further, how about:
mp_integer from = std::max(0, *from_opt);
- Use
to = std::min(no_timeframes - 1, *to_opt);
These together will avoid unnecessary increments ofc
and permit removing theif
inside thisfor
loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/trans-word-level/property.cpp
Outdated
const exprt &property_expr, | ||
decision_proceduret &solver, | ||
std::size_t no_timeframes, | ||
mp_integer no_timeframes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above: const mp_integer &
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/verilog/sva_expr.h
Outdated
class sva_ranged_always_exprt : public binary_predicate_exprt | ||
{ | ||
public: | ||
explicit sva_ranged_always_exprt(binary_exprt range, exprt op) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for explicit
src/verilog/sva_expr.h
Outdated
class sva_s_always_exprt : public binary_predicate_exprt | ||
{ | ||
public: | ||
explicit sva_s_always_exprt(binary_exprt range, exprt op) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for explicit
#if 0 | ||
else if(src_type.id() == ID_natural) | ||
{ | ||
if(dest_type.id()==ID_integer) | ||
{ | ||
expr = typecast_exprt{expr, dest_type}; | ||
return; | ||
} | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could a comment please be included to explain why this is defined away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the #if 0
This adds support for always property expressions with a given range and for s_always properties.
46f69a6
to
f664e6b
Compare
This adds support for
always
property expressions with a given range.